﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace KWT.DRG_DIP.API.Migrations
{
    /// <inheritdoc />
    public partial class 质控规则库新增 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "qc_Rules",
                columns: table => new
                {
                    QRID = table.Column<string>(type: "varchar(255)", nullable: false, comment: "主键")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ruleCategory = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "规则分类")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ruleName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "规则名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ruleDes = table.Column<string>(type: "varchar(1000)", maxLength: 1000, nullable: false, comment: "规则描述")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    problemCategory = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "问题分类")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ruleLevel = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "规则级别：预警 、强制、高度可疑")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ruleProperties = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "规则属性：一级质控、二级质控、三级质控")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ruleExpressionIn = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "规则表达式(伪代码)")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ruleExpression = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "规则表达式")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ruleJson = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "规则json")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Sort = table.Column<int>(type: "int", nullable: false, comment: "排序"),
                    AddUserID = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "创建人ID")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    AddUserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "创建人名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    AddTime = table.Column<DateTime>(type: "datetime(0)", precision: 0, nullable: false, defaultValueSql: "now()", comment: "创建时间"),
                    UpdUserID = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "创建人ID")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UpdUserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "创建人名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UpdTime = table.Column<DateTime>(type: "datetime(0)", precision: 0, nullable: true, comment: "最后修改时间"),
                    DelUserID = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "创建人ID")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    DelUserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "创建人名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    DelTime = table.Column<DateTime>(type: "datetime(0)", precision: 0, nullable: true, comment: "软删除时间"),
                    IsDel = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "是否软删除")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_qc_Rules", x => x.QRID);
                },
                comment: "质控规则")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "qc_Rules_Fields",
                columns: table => new
                {
                    FDID = table.Column<string>(type: "varchar(255)", nullable: false, comment: "主键")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    FildName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "字段名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    FildDesc = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "字段注释")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    FildLocation = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "字段位置")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    FildRemark = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "字段备注")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    FildNameInnert = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "字段内部名称")
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_qc_Rules_Fields", x => x.FDID);
                },
                comment: "质控规则--字段表")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "qc_Rules_ValueRange",
                columns: table => new
                {
                    VRID = table.Column<string>(type: "varchar(255)", nullable: false, comment: "主键")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    name = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "值域名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    remark = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "值域备注")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Sort = table.Column<int>(type: "int", nullable: false, comment: "排序"),
                    AddUserID = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "创建人ID")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    AddUserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "创建人名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    AddTime = table.Column<DateTime>(type: "datetime(0)", precision: 0, nullable: false, defaultValueSql: "now()", comment: "创建时间"),
                    UpdUserID = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "创建人ID")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UpdUserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "创建人名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UpdTime = table.Column<DateTime>(type: "datetime(0)", precision: 0, nullable: true, comment: "最后修改时间"),
                    DelUserID = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "创建人ID")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    DelUserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "创建人名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    DelTime = table.Column<DateTime>(type: "datetime(0)", precision: 0, nullable: true, comment: "软删除时间"),
                    IsDel = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "是否软删除")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_qc_Rules_ValueRange", x => x.VRID);
                },
                comment: "质控规则--值域")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "qc_Rules_ValueRangeInfo",
                columns: table => new
                {
                    ID = table.Column<string>(type: "varchar(255)", nullable: false, comment: "主键")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    VRID = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "值域ID")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Code = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "编码")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Name = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, defaultValue: "", comment: "名称")
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_qc_Rules_ValueRangeInfo", x => x.ID);
                },
                comment: "质控规则--值域明细")
                .Annotation("MySql:CharSet", "utf8mb4");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "qc_Rules");

            migrationBuilder.DropTable(
                name: "qc_Rules_Fields");

            migrationBuilder.DropTable(
                name: "qc_Rules_ValueRange");

            migrationBuilder.DropTable(
                name: "qc_Rules_ValueRangeInfo");
        }
    }
}
